﻿using BBCore.Core.Models.BaseModels;
using FreeSql;
using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BBCore.Core.Models.Admins
{
    [Table(Name = "HYJ_MENU")]
    [Description("菜单表")]
    public class MenuEntity : BaseEntity<MenuEntity, int>
    {       
        [Display(Name = "菜单名")]
        [Required(ErrorMessage = "菜单名不能为空")]
        public string? MenuName { get; set; }
      
        [Display(Name = "URL")]
        [Required(ErrorMessage = "URL不能为空")]
        public string? Url { get; set; }


        [Display(Name = "图标")]
        [Required(ErrorMessage = "图标不能为空")]
        public string? Icon { get; set; }

        [Display(Name = "父级ID")]
        public int ParentId { get; set; }

        [Navigate(nameof(ParentId))]
        public MenuEntity? Parent { get; set; }

        [Navigate(nameof(ParentId))]
        public List<MenuEntity>? Children { get; set; }

        [Navigate(ManyToMany = typeof(RoleMenuEntity))]
        public List<RoleEntity>? Roles { get; set; }


        
        [DisplayName("中文标题")]
        public string? CN_COLUMNS { get; set; }
        [DisplayName("Sql语句")]
        public string? Query_Sql { get; set; }
        /// <summary>
        /// 查询栏信息
        /// </summary>
        [DisplayName("查询栏信息")]
        //导航属性，OneToMany
        [Navigate(nameof(ControlDetails.Menu_AuthId))]
        public virtual List<ControlDetails>? Query_Info { get; set; } = new List<ControlDetails>();
    }
}
